const test = require('tape');
const CryptoUtils = require('../../src/CryptoUtils');

test('CryptoUtils', function (t) {
    let pub = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQ3IMKdifm43Ue0FDEZNBDPgaHaysBEOsfZbwOnl6UvMXUKsOGVwA3X2tyDvg4gWe1WgjanRkXfQHjQI0sqA4cJx6T7LLN1kYdAPuYYXII8R8AEme4N1ROi9CxXGEyNE9o3g0KHdUs5chrcatYb0y4tatsjCQ/kiu/0eU84wvAUQIDAQAB
-----END PUBLIC KEY-----`
    let miwen = `LXwcvgVqnp431kYPAPjfoASbUwH7Ro33rL/nnNHKseg+A9PX2WqyeZus0Wf8dHx+F5EwRJNgAcH6tnPZwd6zaWiL9vSfpd/F2CQHTdz0apd5NnRg81MRjhN8LnsA5StgbZuXNAfpo0cS9oTlAvrZcWKHKORrh7ffWkHvblBk6sR1QPVJPzfFckoh4GUGyG3IH5EOuheeLoPd2tFQse09GuIlaKD+wXDXFFjx1Ip23Ujhadu9a825GJC0JwdPti0xnrGOYdfpls8pGUl48mUdjig+8jHMDf7rk9Mr6M0esyb6PkPsrEhrfrzm/EH0b1OIsXF7wMwsenevA4bZDhzK1Rrt0xmS2QHq+MfyNooDuCjcYxAWlY8vvE6ce6eZgr+r2vi6xINVITpWaM8uyJQh3fXljLREQ8yD/PDfLe6xXxD8Cg+1DJh/Rq5IOjb5bJ+TeV2kYbSQCd6j2tXcELdkUvlHrSAgLvHSy+sJroAzUb4hFVP+L5IE258mMQygCWzI`

    let text = `测试`
    let res1 = CryptoUtils.encryptByRSA(pub,text)
    console.log(res1)

    let res2 = CryptoUtils.decryptByRSAPub(pub,miwen)
    console.info(res2)

    let s = `iX0U5CwIQmTnX680v46669TPns9rYQ3W2YBTO3E+fAOiy+LXxWbDBSqwzeW1IFZ1dIu7P1u04wbPZKxuNqZ1WRVuy8vITmz4PjFNphrwy8Oaz15jefkA6MJxyQFnFXzsDTtye1+/nHMZCWMP+i6OT8gvxFxrygKLshGzkax600g=`
    let content = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQ3IMKdifm43Ue0FDEZNBDPgaHaysBEOsfZbwOnl6UvMXUKsOGVwA3X2tyDvg4gWe1WgjanRkXfQHjQI0sqA4cJx6T7LLN1kYdAPuYYXII8R8AEme4N1ROi9CxXGEyNE9o3g0KHdUs5chrcatYb0y4tatsjCQ/kiu/0eU84wvAUQIDAQAB`
    let res = CryptoUtils.verifyBySHA256WithRSA(pub,s,content)
    console.log(res)
    t.end();
});